package io.github.talelin.latticy.service.impl.ag;

import io.github.talelin.latticy.dto.ag.exceptionDataPush.CreateOrUpdateExceptionDataPushDTO;
import io.github.talelin.latticy.mapper.ag.ExceptionDataPushMapper;
import io.github.talelin.latticy.model.ag.ExceptionDataPushDO;
import io.github.talelin.latticy.service.ag.ExceptionDataPushService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ExceptionDataPushServiceImpl implements ExceptionDataPushService {
    @Autowired
    private ExceptionDataPushMapper mapper;

    @Override
    public ExceptionDataPushDO getById(int id) {
        return mapper.selectById(id);
    }

    @Override
    public List<ExceptionDataPushDO> getExceptionDatas() {
        return mapper.selectList(null);
    }

    @Override
    public boolean createExceptionData(CreateOrUpdateExceptionDataPushDTO validator) {
        ExceptionDataPushDO exceptionData = new ExceptionDataPushDO();
        exceptionData.setMoId(validator.getMo_id());
        exceptionData.setPushTime(validator.getPush_time());
        return mapper.insert(exceptionData) > 0;
    }

    @Override
    public boolean deleteById(int id) {
        return mapper.deleteById(id) > 0;
    }

    @Override
    public boolean updataExceptionData(ExceptionDataPushDO exceptiondata, CreateOrUpdateExceptionDataPushDTO validator) {
        exceptiondata.setMoId(validator.getMo_id());
        exceptiondata.setPushTime(validator.getPush_time());
        return mapper.updateById(exceptiondata) > 0;
    }
}
